var stroage = window.localStorage

function setItem(key, value) {
  if(stroage) {
    stroage.setItem(key, JSON.stringify(value))
  } else {
    console.log("浏览器不支持")
;  }
}

function getItem(key) {
  if(stroage) {
    return JSON.parse(stroage.getItem(key));
  } else {
    console.log("浏览器不支持")
;  }
}

function clear() {
  if(stroage) {
    stroage.clear()
  } else {
    console.log("浏览器不支持")
  }
}

function setCity(cityId,cityName) {
  var city = {
    id:cityId,
    cityName:cityName
  };
  stroage.setItem("city", JSON.stringify(city));
}

module.exports = {
    setItem: setItem,
    getItem: getItem,
    clear: clear,
  setCity:setCity
}
